package sjsu.android;

import java.sql.Date;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageButton;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import dbAdapter.CreateFoodData;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;



public class mainmenu extends Activity {
    /** Called when the activity is first created. */
	private ImageButton btnProfile;
	private ImageButton btnFood;
	private ImageButton btnExercise;
	private ImageButton btnReports;
	private ImageButton btnSearch;
	private ImageButton btnNutrition;
	
//	 public DBSetup ds;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
  //      ds  = new DBSetup();
   //     CreateFoodData fd = new CreateFoodData();
   //     fd.create(this);
        btnProfile = (ImageButton) this.findViewById(R.id.Profile);
		btnProfile.setOnClickListener(ProfileListener);
		btnFood = (ImageButton) this.findViewById(R.id.Food);
		btnFood.setOnClickListener(FoodListener);
		btnExercise = (ImageButton) this.findViewById(R.id.Exercise);
		btnExercise.setOnClickListener(ExerciseListener);
		btnReports = (ImageButton) this.findViewById(R.id.Reports);
		btnReports.setOnClickListener(ReportsListener);
		btnSearch = (ImageButton) this.findViewById(R.id.Search);
		btnSearch.setOnClickListener(SearchListener);
		btnNutrition = (ImageButton) this.findViewById(R.id.Nutrition);
		btnNutrition.setOnClickListener(NutritionListener);
		

        
    }
    
    private OnClickListener ProfileListener = new OnClickListener() {
		public void onClick(View v) {
			Intent intent = new Intent(mainmenu.this, Profile.class);
	   		 startActivity(intent);
		}
	};
	
	private OnClickListener FoodListener = new OnClickListener() {
		public void onClick(View v) {
		Intent intent = new Intent(mainmenu.this, Food.class);
   		 startActivity(intent);
			

		}
	};
	
	private OnClickListener ExerciseListener = new OnClickListener() {
		public void onClick(View v) {
			Intent intent = new Intent(mainmenu.this, Exercise.class);
			   		 startActivity(intent);
						

		}
	};
	
	private OnClickListener ReportsListener = new OnClickListener() {
		public void onClick(View v) {
			// TODO Auto-generated method stub
			final String items[] = {"Daily Report","Weekly Report","Monthly Report"};
			AlertDialog.Builder ab=new AlertDialog.Builder(mainmenu.this);
			ab.setTitle("Select Report type");
			ab.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int whichButton) {
					if (whichButton == 0){
						Intent intent = new Intent(mainmenu.this, DailyReportActivity.class);
						intent.putExtra("Date", new Date(110, 9, 10).toString());
						startActivity(intent);
					}

					else if (whichButton == 1){
						Intent intent = new Intent(mainmenu.this, WeeklyReportActivity.class);
						startActivity(intent);
					}
					else if (whichButton == 2){
						Intent intent = new Intent(mainmenu.this, MonthlyReportActivity.class);
					startActivity(intent);
				}

				}
			});
					
			ab.show();

	//		Intent intent = new Intent(mainmenu.this, Reports.class);
	//		   		 startActivity(intent);
						

		}
	};
	
	private OnClickListener SearchListener = new OnClickListener() {
		public void onClick(View v) {
		Intent intent = new Intent(mainmenu.this, SearchActivity.class);
			   		 startActivity(intent);
						

		}
	};
	
	private OnClickListener NutritionListener = new OnClickListener() {
		public void onClick(View v) {
			Intent intent = new Intent(mainmenu.this, Nutrition.class);
			   		 startActivity(intent);
						

		}
	};
}